package com.wzf.controller;

import com.google.gson.Gson;
import com.wzf.apis.OrderServiceFeign;
import com.wzf.pojo.UserInfo;
import com.wzf.pojo.resp.ResponseReuslt;
import com.wzf.service.UserInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 用户表 前端控制器
 * @author wzf
 * @since 2024-08-03
 */
@RestController
@Slf4j
@Tag(name = "用户信息类")
public class UserInfoController {

    @Resource
    private OrderServiceFeign orderServiceFeign;

    @Resource
    private UserInfoService userInfoService;

    @GetMapping("info")
    @Operation(summary = "用户信息查询",description = "用户信息查询")
    public ResponseReuslt listUser(){
        Map<String, Object> result = new HashMap<>();
        result.put("张三",12);
        result.put("李四",12);
        ResponseReuslt order = orderServiceFeign.getOrder();
        log.info(new Gson().toJson(order));
        Date date = new Date();
        System.out.println(date);
        result.put("date",date);
        return ResponseReuslt.builder().data(result);
    }

    @PostMapping("save")
    @Operation(summary = "用户新增")
    public ResponseReuslt saveUser(@RequestBody UserInfo userInfo){

        boolean save = userInfoService.save(userInfo);

        return ResponseReuslt.ok();
    }

}

